package com.woniuxy01;

import java.util.Arrays;
import java.util.Random;

/**
 * @author 作者
 * @create 2025-09-10 10:42
 */
public class Test02 {
    public static void main(String[] args) {
        System.out.println(System.currentTimeMillis());
        int i=1;
//        if (i==1) {
//            System.exit(0);
//            return;
//        }
        testExit();
        System.out.println("aaa");
    }

    static void testExit(){
        int i=1;
        if(i==1){
//            System.exit(0);
            return;
        }
    }

    private static void test09() {
        int[] a = {1, 2, 3};
        System.out.println(Arrays.toString(a));
        a = Arrays.copyOf(a, a.length + 1);
        System.out.println(Arrays.toString(a));
        //添加元素的下标和值
        int index = 1, num = 9;
        System.arraycopy(a, index, a, index + 1, a.length - index - 1);
        System.out.println(Arrays.toString(a));
        a[index] = num;
        System.out.println(Arrays.toString(a));
    }

    private static void test08() {
        int[] src = {1, 2, 3};
        int srcPos = 0;
        int[] dest = new int[5];
        int destPos = 2;
        int length = 3;
        //Object src,   原始数组
        // int  srcPos, 从原始数组的第几个元素开始复制
        //Object dest,  目标数组，扩容以后的数组
        // int destPos, 从目标数组的第几个元素开始赋值
        //int length    从原始数组复制多少个元素到目标数组
        System.arraycopy(src, srcPos, dest, destPos, length);
        System.out.println(Arrays.toString(src));
        System.out.println(Arrays.toString(dest));
    }

    private static void test07() {
        int[] a = {1, 2, 3};
        //数组扩容
        System.out.println(Arrays.toString(a));
        a = Arrays.copyOf(a, 10);
        System.out.println(Arrays.toString(a));
    }

    private static void test06() {
        System.out.println(Math.random());
        Random random = new Random();
        random.nextInt();
        random.nextInt(100);
        for (int i = 1; i <= 10; i++) {
            System.out.println(random.nextInt(10, 100));
        }
    }

    private static void test05() {
        System.out.println(Math.random());
        System.out.println(Math.max(1, 5));
        //指数运算
        System.out.println(Math.pow(2, 10));
        //向下取整
        System.out.println(Math.floor(2.1));
        //向上取整
        System.out.println(Math.ceil(2.1));
    }

    private static void test04() {
        Character c = 'a';
        System.out.println(Character.isDigit('a'));
        System.out.println(Character.isDigit('1'));
    }

    private static void tst03() {
        //自动装箱
//        Integer i=127;
//        Integer j=127;
        Integer i = Integer.valueOf(127);
        Integer j = Integer.valueOf(127);
        System.out.println(i == j);
        System.out.println(i.equals(j));
    }

    private static void test03() {
        String str = "123";
        //字符串转整数
        Integer i = Integer.valueOf(str);
        System.out.println(str + 123);
        System.out.println(i + 123);
    }

    private static void test02() {
        int a = 1;
        //装箱
        Integer i = new Integer(a);
        Integer k = Integer.valueOf(a);
        //JDK1.5自动装箱拆箱
        //语法糖:新版本引入了新的语法，简化了代码，底层实现没有变，方便程序员
        Integer j = a;
        //自动拆箱
        int b = j;
        //JDK1.5之前的写法
        int c = j.intValue();
    }

    private static void test01() {
        System.out.println(Integer.MAX_VALUE);
        System.out.println(Integer.MIN_VALUE);
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
    }
}
